import { Args, Mutation, Resolver } from '@nestjs/graphql';
import { LoginService } from './login.service';
import { Result } from '../../dto/result.type';

@Resolver()
export class LoginResolver {
  constructor(private readonly authService: LoginService) {}

  @Mutation(() => Result, { description: '登录' })
  async login(
    @Args('code', { nullable: true }) code: string,
    @Args('tel', { nullable: true }) tel: string,
    @Args('account', { nullable: true }) account: string,
    @Args('password', { nullable: true }) password: string,
    @Args('isStudent') isStudent: boolean,
  ): Promise<Result> {
    return await this.authService.login(
      tel,
      code,
      account,
      password,
      isStudent,
    );
  }
}
